﻿using System.Linq;

namespace Complaint.Repositories
{
    /// <summary>
    /// Represents a series of methods that define how a specified type can interact with a data store.
    /// </summary>
    /// <typeparam name="T">The type of the instance to work on.</typeparam>
    public interface IRepository<T>
    {
        /// <summary>
        /// Creates the passed instance of the type to the data store.
        /// </summary>
        /// <param name="dataTransferObject">The instance of the type to create to the data store.</param>
        void Create(T dto);

        /// <summary>
        /// Updates the passed instance of the type to the data store.
        /// </summary>
        /// <param name="dataTransferObject">The instance of the type to update to the data store.</param>
        void Update(T dto);

        /// <summary>
        /// Deletes an instance of the type by its given ID from the data store.
        /// </summary>
        /// <param name="id">The ID of the instance to delete.</param>
        void Delete(T dto);

        /// <summary>
        /// Retrieves all instances of the type T.
        /// </summary>
        /// <returns>The requested instances.</returns>
        IQueryable<T> FindAll();

        /// <summary>
        /// Retrieves an instance of the type T by its given ID from the data store.
        /// </summary>
        /// <param name="id">The ID of the instance to retrieve.</param>
        /// <returns>The requested instance.</returns>
        T FindById(int id);

        /// <summary>
        /// Retrieves an instance of the type T by its given name from the data store.
        /// </summary>
        /// <param name="name">The name of the instance to retrieve.</param>
        /// <returns>The requested instance.</returns>
        IQueryable<T> FindByName(string name);
    }
}